/*
   Project AwesOmeScript
   Copyright 2010 Domenico Gentner

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MAINFRAME_HPP
#define MAINFRAME_HPP

class IViewbase;
class Project;
class IconBrowser;

struct Version
{
	Version()
		: major(0), minor(0), patch(0)
	{}
	
	Version( int ma, int mi, int pa )
		: major(ma), minor(mi), patch(pa)
	{}
	
	int major;
	int minor;
	int patch;

	bool operator==(const Version& rhs)
	{
		return( major == rhs.major && minor == rhs.minor && patch == rhs.patch );
	}

	operator const wxString() const
	{
		wxString s;
		s << major << "." << minor << "." << patch;
		return s;
	}
};

struct HtmlReplacements
{
	wxString display;
	wxString real;
};


// Mainframe class
class Mainframe : public wxFrame
{
public:
	//////////////////////////////////////////////////////////////////////////
	// Constructors
	explicit Mainframe(long style);
	virtual ~Mainframe();

	void TellVersion(wxString v);
	void InsertIcon(const wxString& display);

protected:
	//////////////////////////////////////////////////////////////////////////
	// Events
	void OnOpenProject(wxCommandEvent&);
	void OnSaveProject(wxCommandEvent&);
	void OnSaveProjectAs(wxCommandEvent&);
	void OnExit(wxCommandEvent&);
	void OnAbout(wxCommandEvent&);
	void OnReloadHtml(wxCommandEvent&);
	void OnShowStartup(wxCommandEvent&);
	void OnCheckNotebookView(wxCommandEvent&);
	void OnCheckSplitView(wxCommandEvent&);
	void OnSetAODir(wxCommandEvent&);	
	void OnExportScriptToAo(wxCommandEvent&);
	void OnNewProject(wxCommandEvent&);
	void OnShowProjectProperties(wxCommandEvent&);
	void OnUndo(wxCommandEvent&);
	void OnRedo(wxCommandEvent&);
	void OnToggleWordWrap(wxCommandEvent&);
	void OnToggleLineNumbers(wxCommandEvent&);
	void OnSelectFont(wxCommandEvent&);
	void OnResetSettings(wxCommandEvent&);
	void OnHtmlEditModified(wxStyledTextEvent&);
	void OnCheckVersion(wxCommandEvent&);	
	void OnSettings(wxCommandEvent&);
	void OnClose(wxCloseEvent&);
	void OnImportIcons(wxCommandEvent&);

	//////////////////////////////////////////////////////////////////////////
	// HTML Command Helper
	void OnAddNewLine(wxCommandEvent&);
	void OnSelectHtmlColor(wxCommandEvent&);
	void OnAddCenterHtml(wxCommandEvent&);
	void OnShowIconBrowser(wxCommandEvent&);

	//////////////////////////////////////////////////////////////////////////
	// Changing the view
	void ChangeView(const wxString& view);

	//////////////////////////////////////////////////////////////////////////
	// Helper for getting the AODir
	wxString GetAnarchyDirectoryFromRegistry();
	void AskUserForSaveOnModifiedProject();

	wxString DoRegExOnString(wxString& text);


private:
	DECLARE_EVENT_TABLE();

	IViewbase* m_viewbase;
	wxString   m_aodir;
	Project*   m_project;
	int		   m_max_textlength;
	bool	   m_menu_needs_unlock;
	IconBrowser* m_icon_browser;
};

#endif // MAINFRAME_HPP
